package com.abysscore.yachtdesign;

import java.awt.Color;
/*
 *    {---------------------------------------------------------------------------------------------------}
     {                                       TFreeIntersection                                           }
     {                                                                                                   }
     {   TFreeIntersection is a list of curves calculated from the intersection of a                     }
     {   ship hull (represented by a subdivision surface) and a plane.                                   }
     {   This plane can be a orthogonal plane (eg. stations, waterlines, buttocks) or a freely oriented  }
     {   3D plane (sent)                                                                                 }
     {---------------------------------------------------------------------------------------------------}
 */
public class TFreeIntersection {
	private TFreeShip FOwner;
	private TFasterList FItems;
	private TFreeIntersectionType FIntersectionType;
	private T3DPlane FPlane;
	private boolean FBuild;
	private boolean FShowCurvature;
	private boolean FUseHydrostaticsSurfacesOnly; // used for lateral area, mainframe and waterplane properties
	
	
	private Color FGetColor()
	{
		Color Result;
		switch(FIntersectionType) 
		{
		case fiStation: 
			Result = FOwner.Preferences().StationColor();
			break;
		case fiButtock: 
			Result = FOwner.Preferences().ButtockColor();
			break;
		case fiWaterline:
			Result = FOwner.Preferences().WaterlineColor();
			break;
		case fiDiagonal:
			Result = FOwner.Preferences().DiagonalColor();
		    break;
		default: 
			Result = Color.WHITE;
		}
		return Result;
	}
	private T3DPlane FGetPlane()
	{
		return FPlane;
	}
	private int FGetCount()
	{
		return 0;
	}
	private String FGetDescription()
	{
		return "";
	}
	private TFreeSpline FGetItem(int Index)
	{	
		return null;
	}
	private void FSetBuild(boolean Val)
	{
		FBuild = Val;
	}
	
	
           
	 public void Add(TFreeSpline Item)
	 {
		 ;
	 }
	 public void CalculateArea(T3DPlane Plane,TFloatType Area, T3DCoordinate COG, T2DCoordinate MomentOfInertia)
	 {
		 ;
	 }
	 public void Clear()
	 {
		 ;
	 }
	 public TFreeIntersection(TFreeShip Owner)
	 {
		 FOwner = Owner;
	 }
	 public void CreateStarboardPart()
	 {
		 ;       // Create the starboardhalf of the ship, for use in hydrostatic calculations
	 }
	 public void Delete(boolean Redraw)
	 {
		 ;
	 }
	 public void DeleteItem(TFreeSpline Item)
	 {
		 int Index;
		 Index = FItems.IndexOf(Item);
		 if (Index>=0)
			 FItems.Delete(Index);
	 }
	 //public destructor  Destroy;                                                       override;
	 public void Draw(TFreeViewport Viewport)
	 {
		 ;
	 }
	 public void DrawAll()
	 {
		 ;
	 }
	 public void Extents(T3DCoordinate Min, T3DCoordinate Max)
	 {
		 ;
	 }
	 public void LoadBinary(TFreeFileBuffer Source)
	 {
		 int I=0;
		 int J=0;
		 int M=0;
		 int N=0;
		 TFreeSpline Spline=null;
		 T3DCoordinate P=null;
		 boolean Bool=false;
		
		 Source.Load(I);
		 FIntersectionType=TFreeIntersectionType.values()[I];
		 if (FOwner.FileVersion().compareTo(TFreeFileVersion.fv191)>=0)
		 {
			 Source.Load(FShowCurvature);
		 }
		 else 
			 FShowCurvature=false;
		 Source.Load(FPlane);
		 Source.Load(FBuild);
		 Source.Load(N);
		 FItems.Capacity(N);
		 for (I=1; I<=N; I++)
		 {
			 Spline=new TFreeSpline();
			 FItems.Add(Spline);
			 // Read number of points for this spline
			 Source.Load(M);
			 // Read actual 3D coordinates
			 Spline.Capacity(M);
			 for (J=1; J<=M; J++)
			 {
				 if (FOwner.FileVersion().compareTo(TFreeFileVersion.fv160)>=0)
				 {
					 if (IntersectionType()==TFreeIntersectionType.fiStation)
					 {
						 P.X=-FPlane.d;
						 Source.Load(P.Y);
						 Source.Load(P.Z);
					 }
					 else if (IntersectionType()==TFreeIntersectionType.fiButtock)
					 {
						 Source.Load(P.X);
						 P.Y=-FPlane.d;
						 Source.Load(P.Z);
					 } 
					 else if (IntersectionType()==TFreeIntersectionType.fiWaterline)
					 {
						 Source.Load(P.X);
						 Source.Load(P.Y);
						 P.Z=-FPlane.d;
					 }
					 else 
						 Source.Load(P);
				 }
				 else 
					 Source.Load(P);
				 Spline.Add(P);
		         Source.Load(Bool);
		         Spline.Knuckle(J-1,Bool);
			 }
		 }
	 }
	 public void Rebuild()
	 {
		 ;
	 }
	 public void SaveToDXF(TStringList Strings)
	 {
		 ;
	 }
	 public void SaveBinary(TFreeFileBuffer Destination)
	 {
		 ;
	 }
	 
	 
	 public boolean Build() { return FBuild; }
	 public void Build(boolean val) { FSetBuild(val); }
	 public Color Color() { return FGetColor(); }
	 public int Count() { return FGetCount(); }
	 public String Description() { return FGetDescription(); }
	 public TFreeIntersectionType IntersectionType() { return FIntersectionType; }
	 public void IntersectionType(TFreeIntersectionType val) { FIntersectionType = val; }
	 public TFreeSpline Items(int index) {return FGetItem(index); }
	 public TFreeShip Owner() { return FOwner; }
	 public T3DPlane Plane() { return FGetPlane(); }
	 public void Plane(T3DPlane val) { FPlane = val; }
	 public boolean ShowCurvature() { return FShowCurvature; }
	 public void ShowCurvature(boolean val) { FShowCurvature=val; }
	 public boolean UseHydrostaticsSurfacesOnly() { return FUseHydrostaticsSurfacesOnly; }
	 public void UseHydrostaticsSurfacesOnly(boolean val) { FUseHydrostaticsSurfacesOnly=val; }
}
